package org.apache.tapestry5.csrfprotection.tests.explicit.pages;

import java.util.ArrayList;

import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.csrfprotection.CsrfProtected;

/**
 * Simple page with a form component that is tested in combination with the cross request forgery protection.
 */
public class FormAttack
{		
	@Property
	@Persist
	private String message;

	@Property
	@Persist
	private ArrayList<String> messages;
	
	@Log
	@CsrfProtected
	Object onSuccess(){
		messages.add(message);		
		return this;
	}
	
	@Log
	void onActivate(){
		if(messages == null){
			messages = new ArrayList<String>();
		}
	}
}